<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加应用</title>
    <link rel="stylesheet" href="../../static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="../../static/frame/static/css/style.css">
    <link rel="icon" href="../../static/frame/static/image/code.png">
</head>
<body class="body">

<div class="layui-row layui-col-space10 my-index-main">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">应用名称</label>
            <div class="layui-input-block">
                <input type="text" name="app_name" required lay-verify="required" placeholder="请输入应用名称"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">

            <label class="layui-form-label">相关选项</label>
            <div class="layui-input-block">
                <input type="checkbox" name="bdip" title="绑定IP" checked>
                <input type="checkbox" name="bdjq" title="绑定机器" checked>
                <input type="checkbox" name="bdqq" title="绑定QQ" checked>
                <input type="checkbox" name="zxjc" title="在线检测" lay-filter="zxjc" checked>
                <input type="checkbox" name="yxhb" title="允许换绑" checked>
                <input type="checkbox" name="yxjb" title="允许解绑" checked>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登陆方式</label>
            <div class="layui-input-block">
                <input type="radio" name="sqfs" value="kmsq" title="卡密授权">
                <input type="radio" name="sqfs" value="zhmm" title="账号密码" checked>
                <input type="radio" name="sqfs" value="jcbd" title="检查绑定">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">使用方式</label>
            <div class="layui-input-block">
                <input type="radio" name="syfs" value="kcye" title="余额点数">
                <input type="radio" name="syfs" value="dqsj" title="到期时间" checked>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">周期扣除</label>
            <div class="layui-input-block">
                <input type="text" name="zqkc" required lay-verify="required" placeholder="周期扣除的点数" autocomplete="off"
                       class="layui-input">
                <div class="layui-form-mid layui-word-aux">每分钟扣除的余额点数，仅使用方式为扣除余额时候有效</div>
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">换解扣除</label>
            <div class="layui-input-block">
                <input type="text" name="jbkc" required lay-verify="required" placeholder="换绑/解绑扣除的授权数量" autocomplete="off"
                       class="layui-input">
                <div class="layui-form-mid layui-word-aux">如果使用方式为扣除余额，则为扣除的余额数量(点)，如果使用方式为到期时间，则为扣除的使用分钟数</div>

            </div>
        </div>

        <div class="layui-form-item layui-hide" hidden>
            <label class="layui-form-label">充值面值</label>
            <div class="layui-input-block">
                <input type="text" name="czmz" placeholder="充值卡密对应面值" autocomplete="off"
                       class="layui-input">
                <div class="layui-form-mid layui-word-aux">如果使用方式为扣除余额，则一元钱等于多少余额数量(点)，如果使用方式为到期时间，则一元钱等于多少分钟使用授权</div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">在线周期</label>
            <div class="layui-input-block">
                <input type="text" name="zxms" required lay-verify="required" placeholder="单位：秒" autocomplete="off"
                       class="layui-input">
                <div class="layui-form-mid layui-word-aux">推荐为软件授权心跳间隔秒数 × 1.5，注意：小于1会导致数据库数据大量沉余而增加大量资源消耗和大幅减慢API速度，当超过3个周期未心跳将会自动下线（即此处设置10，30秒内均无心跳则token失效下线，需要用户重新登录）</div>
            </div>
        </div>
        <div class="layui-form-item" hidden>
            <label class="layui-form-label">注册赠送</label>
            <div class="layui-input-block">
                <input type="text" name="zczs" required lay-verify="required" placeholder="注册赠送" autocomplete="off"
                       class="layui-input" disabled value="0">
                <div class="layui-form-mid layui-word-aux">已弃用</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">应用公告</label>
            <div class="layui-input-block">
                <input type="text" name="yygg" required lay-verify="required" placeholder="输入公告" autocomplete="off"
                       class="layui-input">
                <div class="layui-form-mid layui-word-aux">应用公告通过获取应用信息进行返回</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">应用版本</label>
            <div class="layui-input-block">
                <input type="text" name="yybb" required lay-verify="required" placeholder="请输入应用版本" autocomplete="off"
                       class="layui-input">
                <div class="layui-form-mid layui-word-aux">只能是标准的小数格式，若需要1.1.101这种格式请在软件内置版本说明常量，此处仅判断软件是否有新版</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">更新日志</label>
            <div class="layui-input-block">
                <input type="text" name="gxrz" required lay-verify="required" placeholder="输入软件更新日志" autocomplete="off"
                       class="layui-input">
                <div class="layui-form-mid layui-word-aux">通过获取应用信息返回</div>
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">免费模式</label>
            <div class="layui-input-block">
                <input type="checkbox" name="mfms" lay-skin="switch" lay-text="开启|关闭">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">强制更新</label>
            <div class="layui-input-block">
                <input type="checkbox" name="qzgx" lay-skin="switch" lay-text="开启|关闭">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">下载地址</label>
            <div class="layui-input-block">
                <input type="text" name="gxdz" required lay-verify="required" placeholder="请输入地址" autocomplete="off"
                       class="layui-input">
                <div class="layui-form-mid layui-word-aux">可以是百度云链接、或者下载绝对地址等等，获取应用信息中的下载地址和首页下载应用都会是这个地址</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">自定义数据</label>
            <div class="layui-input-block">
                <input type="text" name="zdysj" required lay-verify="required" placeholder="自定义数据" autocomplete="off" class="layui-input">
                <div class="layui-form-mid layui-word-aux">用户授权成功后才能获取这个，建议将一些重要数据放在这里面</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">添加应用</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="../../static/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../static/frame/layui/layui.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script type="text/javascript" src="../../static/frame/echarts/echarts.min.js"></script>
<script type="text/javascript">
    layui.use(['form', 'element', 'layer', 'vip_tab'], function () {
        $('.my-nav-btn').on('click', function () {
            if ($(this).attr('data-href')) {
                //vipTab.add('','标题','路径');
                vipTab.add($(this), '<i class="layui-icon">' + $(this).find("button").html() + '</i>' + $(this).find('p:last-child').html(), $(this).attr('data-href'));
            }
        });
        var form = layui.form;
        form.on('submit(formDemo)', function (data) {
            var loading = layer.load();
            $.ajax({
                url: '../ajax.php?mod=addapp',
                type: 'POST',
                dataType: 'json',
                data: 'app_name=' + data.field.app_name + '&bdip=' + data.field.bdip + '&bdjq=' + data.field.bdjq + '&bdqq=' + data.field.bdqq + '&zxjc=' + data.field.zxjc + '&yxhb=' + data.field.yxhb + '&yxjb=' + data.field.yxjb + '&sqfs=' + data.field.sqfs + '&syfs=' + data.field.syfs + '&jbkc=' + data.field.jbkc + '&czmz=' + data.field.czmz + '&zxms=' + data.field.zxms + '&zczs=' + data.field.zczs + '&yygg=' + data.field.yygg + '&yybb=' + data.field.yybb + '&gxrz=' + data.field.gxrz + '&gxdz=' + data.field.gxdz + '&qzgx=' + data.field.qzgx+ '&mfms=' + data.field.mfms + '&zqkc=' + data.field.zqkc + '&zdysj=' + data.field.zdysj,
                success: function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.alert('应用添加成功！<br>应用ID：' + data.appid + '<br>Connectkey：' + data.Connectkey + '<br>Decryptkey：' + data.Decryptkey);
                    } else {
                        layer.msg(data.msg);
                    }
                },
                error: function (data) {
                    layer.close(loading);
                    layer.msg('['+data.status+']'+data.statusText);
                }
            });
            return false;
        });
        form.on('checkbox(zxjc)', function (obj) {
            layer.msg('请注意：<br>如果开启在线检测则只能同时在一个地方使用授权<br>如果关闭则允许在多个地方使用同一个授权')
        });
    });
</script>
</body>
</html>